<?php
/**
 * Author: ChenGuangHui
 * Email：13035809409@163.com
 * Date Time: 2022/04/13 11:00
 */

namespace App\Models;

use App\Models\Model;

/**
 * App\Models\User
 *
 * @property int $uid
 * @property int $sex 性别:0、保密 1、男 2、女
 * @property string $nickname 昵称
 * @property string $avatar_url 头像
 * @property string $name 真实姓名
 * @property bool $status 账号状态[0、 正常;1、禁用]
 * @property string $mobile 手机号码
 * @property string|null $openid
 * @property string|null $invite_code 唯一码
 * @property string $password 账户密码
 * @property string|null $remember_token
 * @property \Illuminate\Support\Carbon|null $created_at 创建时间
 * @property \Illuminate\Support\Carbon|null $updated_at 更新时间
 * @method static \Illuminate\Database\Eloquent\Builder|User newModelQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|User newQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|User query()
 * @method static \Illuminate\Database\Eloquent\Builder|User whereAvatarUrl($value)
 * @method static \Illuminate\Database\Eloquent\Builder|User whereCreatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|User whereInviteCode($value)
 * @method static \Illuminate\Database\Eloquent\Builder|User whereMobile($value)
 * @method static \Illuminate\Database\Eloquent\Builder|User whereName($value)
 * @method static \Illuminate\Database\Eloquent\Builder|User whereNickname($value)
 * @method static \Illuminate\Database\Eloquent\Builder|User whereOpenid($value)
 * @method static \Illuminate\Database\Eloquent\Builder|User wherePassword($value)
 * @method static \Illuminate\Database\Eloquent\Builder|User whereRememberToken($value)
 * @method static \Illuminate\Database\Eloquent\Builder|User whereSex($value)
 * @method static \Illuminate\Database\Eloquent\Builder|User whereStatus($value)
 * @method static \Illuminate\Database\Eloquent\Builder|User whereUid($value)
 * @method static \Illuminate\Database\Eloquent\Builder|User whereUpdatedAt($value)
 * @mixin \Eloquent
 * @property int $growth 成长值
 * @property int $point 积分
 * @property int $vip_lev vip等级
 * @property string $balance 余额
 * @property string $register_ip 注册IP
 * @property-read mixed $sex_name
 * @property-read mixed $status_name
 * @property-read mixed $vip_name
 * @method static \Illuminate\Database\Eloquent\Builder|User whereBalance($value)
 * @method static \Illuminate\Database\Eloquent\Builder|User whereGrowth($value)
 * @method static \Illuminate\Database\Eloquent\Builder|User wherePoint($value)
 * @method static \Illuminate\Database\Eloquent\Builder|User whereRegisterIp($value)
 * @method static \Illuminate\Database\Eloquent\Builder|User whereVipLev($value)
 */
class User extends Model
{
    protected $connection = 'store';

    protected $table = 'store_user';

    protected $primaryKey = 'id';

    protected $guarded = [];

    protected $appends = ['status_name', 'sex_name', 'vip_name'];

    /**
     * @return bool
     */
    public function getStatusAttribute()
    {
        return $this->attributes['status'] = $this->attributes['status'] ? true : false;
    }

    
    /**
     * @author ChenGuangHui
     * @dateTime 2022-05-07
     */
    public function getStatusNameAttribute()
    {
        return $this->attributes['status'] == 1 ? '正常' : '禁用';
    }

    /**
     * @author ChenGuangHui
     * @dateTime 2022-05-07
     */
    public function getSexNameAttribute()
    {
        if ($this->attributes['sex'] == 0) {
            return '保密';
        } else {
            return $this->attributes['sex'] == 1 ? '男' : '女';
        }
    }

    
    /**
     * @author ChenGuangHui
     * @dateTime 2022-05-07
     */
    public function getVipNameAttribute()
    {
        return '普通会员';
    }

}
